package com.ssfGame.puremvc.controller.cell
{
	import api.dataStruct.GameApiInfo;
	import api.dataStruct.InitAPIObj;
	import api.dataStruct.ReadStoreVO;
	import api.dataStruct.ServerStoreVO;
	import api.event.CallFunName;
	
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.view.application.SceneLayerMediator;
	import com.ssfGame.puremvc.view.mc.InitAPIBg;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	public class InitBaseAPICommand extends SimpleCommand
	{
		public function InitBaseAPICommand()
		{
			super();
		}
		override public function execute(notification:INotification):void{
			
			init()
		}
		private function init():void{
			
			sendNotification(StaticConst.N_M_SCENE_LAYER_DEL,null,SceneLayerMediator.DEL_ALL);
			sendNotification(StaticConst.N_M_SCENE_LAYER_ADD,new InitAPIBg());
			StaticConst.apiCore.currClass=(this);
			StaticConst.apiCore.startAPI(StaticConst.getInitAPIObj());
		}
	
		public function initAPIcom(myInfo:GameApiInfo):void{
			StaticConst.myInfo=myInfo;
			if(StaticConst.apiType==InitAPIObj.TYPE_1||StaticConst.apiType==InitAPIObj.TYPE_2){
				sendNotification(StaticConst.N_C_INIT_PVP_API);
			}else if(StaticConst.apiType==InitAPIObj.TYPE_5){
				StaticConst.apiCore.callAPIFun(CallFunName.A_READ_STORE,new ReadStoreVO(2,1,onGetStoreVO,"读取用户数据"));
			}else if(StaticConst.apiType==InitAPIObj.TYPE_6){
				onGetStoreVO();
			}
		}
		private function onGetStoreVO(storeVO:ServerStoreVO=null):void{
			sendNotification(StaticConst.N_M_TITLE_ADD);;
		}
		public function startGame(data:Boolean):void{
			StaticConst.apiCore.isRobot=StaticConst.isRobot=data;;//是否和机器人玩,true:为机器人
			sendNotification(StaticConst.N_M_GAME_ADD);
		}
	}
}